#ifndef CXKDVDLLH
#define CXKDVDLLH

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define CRTN_OK                  1
#define CRTN_FAIL                0
#define CRTN_PASS_ERROR          -1

#define PROTOCOL_INFO_VERSION		"DLL_VERSION_17_10_30"
#define LOG_FILE_NAME				"LOG_CHD04.log"
#define LOG_OUTPUT_FILE_DISABLE		-10
#define LOG_OUTPUT_FILE_ENABLE		-11

typedef enum{
	LOG_OUTPUT_DISABLE,
	LOG_OUTPUT_ENABLE
}LOG_OUTPUT_PARAM;

typedef enum{
	MSG_CMD_BEGIN = 0x0,
	INIT_DEVICE,								// 初始化设备， 注意初始化设备后，设备将对后面每次操作作 验证密码处理。
	GET_ID_CODE,								// 获取 IDCODE
	GET_ZFY_INFO,								// 获取 ZFYINFO
	SET_ZFY_INFO,								// 设置 ZFYINFO
	SET_DEV_TIME,								// 设置 设备时间
	SET_MSDC,									// 进入 MASS MODE
	GET_DEV_RESOLUTION,							// 获取分辨率设置
	GET_DEV_BATTERY,							// 获取电量
	SET_ZFY_PASSWD,								// 设置ZFY 密码
	GET_ZFY_PASSWD,								// 获取ZFY 密码
	DEFAULT_SETTING,							// 恢复出厂设置
	GET_DEV_TIME,								// 读取设备时间
	GET_DISKINFO_SETTING,						// 获取磁盘信息

	GET_PARAM_SETTING_VIDEO_RESOLUTION,			// 读取参数设置
	SET_PARAM_SETTING_VIDEO_RESOLUTION,			// 设置参数设置

	GET_PARAM_SETTING_PHOTOSIZE,				// 读取参数设置
	SET_PARAM_SETTING_PHOTOSIZE,				// 设置参数设置

	GET_PARAM_SETTING_RECORDING,				// 读取参数设置
	SET_PARAM_SETTING_RECORDING,				// 设置参数设置

	GET_PARAM_SETTING_SHUTDOWN,					// 读取参数设置
	SET_PARAM_SETTING_SHUTDOWN,					// 设置参数设置

	GET_PARAM_SETTING_INFRARED,					// 读取参数设置
	SET_PARAM_SETTING_INFRARED,					// 设置参数设置

	GET_PARAM_SETTING_VIDEO_QUALITY,			// 读取参数设置
	SET_PARAM_SETTING_VIDEO_QUALITY,			// 设置参数设置

	GET_PARAM_SETTING_VIDEO_SPLIT_TIME,			// 读取参数设置
	SET_PARAM_SETTING_VIDEO_SPLIT_TIME,			// 设置参数设置

	GET_PARAM_SETTING_POST_RECORDING,			// 读取参数设置
	SET_PARAM_SETTING_POST_RECORDING,			// 设置参数设置

	GET_PARAM_SETTING_LCD_BRIGHTNESS,			// 读取参数设置
	SET_PARAM_SETTING_LCD_BRIGHTNESS,			// 设置参数设置

	GET_PARAM_SETTING_CAPTURE,					// 读取参数设置
	SET_PARAM_SETTING_CAPTURE,					// 设置参数设置

	GET_PARAM_VERSION_INFO,						// 版本信息获取（固件版本+DLL版本）
	
	MSG_CMD_END = 0x4f,
}MSG_DEV_CMD;

typedef enum _RESULT_FLAG
{
	CONNECT_SUCCESS = 0x01, /*执法记录仪连接成功*/
	CONNECT_FAILED,         /*执法记录仪连接失败*/
	CHECK_PWD_SUCCESS,      /*执法记录仪管理员密码校验成功*/
	CHECK_PWD_FAILED,       /*执法记录仪管理员密码校验失败*/
	SET_SYSTEMTIME_SUCCESS, /*执法记录仪系统时间同步成功*/
	SET_SYSTEMTIME_FAILED,  /*执法记录仪系统时间同步失败*/
	MSDC_SUCCESS,           /*执法记录仪转换移动磁盘模式成功*/
	MSDC_FAILED,            /*执法记录仪转换移动磁盘模式失败*/
	SET_ZFY_PASSWD_SUCCESS, /*执法记录仪密码设置成功*/
	SET_ZFY_PASSWD_FAILED,  /*执法记录仪密码设置失败*/
	GET_ZFY_PASSWD_SUCCESS, /*执法记录仪密码设置成功*/
	GET_ZFY_PASSWD_FAILED,  /*执法记录仪密码设置失败*/
	DEFAULT_SETTING_SUCCESS,/*恢复出厂设置成功*/
	DEFAULT_SETTING_FAILED, /*恢复出厂设置失败*/
	GET_DEV_TIME_SUCCESS,	/*获取时间成功*/
	GET_DEV_TIME_FAILED,	/*获取时间失败*/
	GET_DISKINFO_SUCCESS,	/*读取磁盘信息*/
	GET_DISKINFO_FAILED,	/*读取磁盘信息*/
	GET_DEV_PARAM_SUCCESS,	/*获取参数成功*/
	GET_DEV_PARAM_FAILED,	/*获取参数失败*/
	SET_DEV_PARAM_SUCCESS,	/*设置参数成功*/
	SET_DEV_PARAM_FAILED,	/*设置参数失败*/
}MSG_DEV_ERROR;


#define PRODUCT_INDEX_LEN					8
#define POLICE_NUMBER_LEN					7
#define USERNAME_LEN						33
#define COMPANY_CODE_LEN					13
#define COMPANY_NAME_LEN					33

#define VENDOR_CODE_LEN						5
#define DATETIME_LEN						14
#define PASSWD_LEN							6

#define MAX_DATA_LEN						512

typedef struct
{
	char  cSerial[PRODUCT_INDEX_LEN];		 /*执法记录仪产品序号，不可为空*/
	char  userNo[POLICE_NUMBER_LEN];         /*执法记录仪使用者警号，不可为空*/
	char  userName[USERNAME_LEN];			 /*执法记录仪使用者姓名，管理系统使用警号关联时可为空*/
	char  unitNo[COMPANY_CODE_LEN];			 /*执法记录仪使用者单位编号，管理系统使用警号关联时可为空*/
	char  unitName[COMPANY_NAME_LEN];		 /*执法记录仪使用者单位名称，管理系统使用警号关联时可为空*/
}ZFY_INFO;


#define USER_MANAGER						(1<<0)
#define USER_NORMAL							(1<<1)
#define USER_DEFAULT						(1<<2)

typedef struct
{
	unsigned char userType;	
	char Manage_passwd[PASSWD_LEN];
	char User_passwd[PASSWD_LEN];
	char Default_passwd[PASSWD_LEN];
}ZFY_PASSWD;

typedef struct{
	unsigned char diskInfo[32];				// disk information
	unsigned int diskSize;					// M 
	unsigned int disk_usedSize;				// used size
	unsigned int disk_reserveSize;			// reserve size
}ZFY_DISKINFO;

typedef struct{
	char dev_param[MAX_DATA_LEN];
}ZFY_PARAM;

typedef struct{
	unsigned short battery;
}DATA_BATTERY;

typedef struct{
	unsigned short width;
	unsigned short height;
}DATA_RESOLUTION;



#ifdef __cplusplus
extern "C"
{
#endif

	int LOG_OUTPUT(LOG_OUTPUT_PARAM lp);

	BOOL  Init_Device(char *cID, unsigned short *usRet);
	BOOL  GetIDCode(char *cID, unsigned short *usRet);
	BOOL  GetZFYInfo(ZFY_INFO *sZfyInfo, char *cPassword, unsigned short *usRet);
	BOOL  WriteZFYInfo(ZFY_INFO *sZfyInfo, char *cPassword, unsigned short *usRet);
	BOOL  SyncDevTime(char *cPassword, unsigned short *usRet);
	BOOL  SetMSDC(char *cPassword, unsigned short *usRet);
	BOOL  ReadDeviceResolution(int *iWidth, int *iHeight, char *cPassword, unsigned short *usRet);
	BOOL  ReadDeviceBatteryDumpEnergy(int *Battery, char *cPassword, unsigned short *usRet);
	BOOL  SetZFYPassword(ZFY_PASSWD* sZfyPasswd, unsigned short *usRet);
	BOOL  GetZFYPassword(ZFY_PASSWD* sZfyPasswd, unsigned short *usRet);
	BOOL  DefaultSetting(char *cPassword, unsigned short *usRet);
	BOOL  GetDevTime(char* time, char* cPassword, unsigned short *usRet);

	BOOL  GetDiskInfo(ZFY_DISKINFO *diskInfo, char* cPassword, unsigned short *usRet);

	BOOL  GetDevParam_Resolution(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);
	BOOL  SetDevParam_Resolution(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);

	BOOL  GetDevParam_PhotoSize(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);
	BOOL  SetDevParam_PhotoSize(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);

	BOOL  GetDevParam_Recording(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);
	BOOL  SetDevParam_Recording(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);
	
	BOOL  GetDevParam_Shutdown(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);
	BOOL  SetDevParam_Shutdown(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);

	BOOL  GetDevParam_Infrared(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);
	BOOL  SetDevParam_Infrared(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);
	
	BOOL  GetDevParam_Video_quality(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);
	BOOL  SetDevParam_Video_quality(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);

	BOOL  GetDevParam_Video_split_time(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);
	BOOL  SetDevParam_Video_split_time(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);
	
	BOOL  GetDevParam_Post_recording(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);
	BOOL  SetDevParam_Post_recording(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);

	BOOL  GetDevParam_Lcd_brightness(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);
	BOOL  SetDevParam_Lcd_brightness(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);
	
	BOOL  GetDevParam_Capture(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);
	BOOL  SetDevParam_Capture(ZFY_PARAM* param,char* cPassword, unsigned short *usRet);

	BOOL  Get_Version_Info(ZFY_PARAM* param, unsigned short *usRet);

#ifdef __cplusplus  
};
#endif 

#endif
